//
//  DHRetweetStatusCell.swift
//  Weibo
//
//  Created by Holfioo on 15/9/9.
//  Copyright © 2015年 Holfioo. All rights reserved.
//

import UIKit

class DHRetweetStatusCell: DHStatusCell {
    // 重写父类方法
    override var statusViewModel: DHStatusViewModel? {
        didSet {
            retweetText.text = statusViewModel?.retweetText
        }
    }
    // 改父类方法为非私有
    override func setupUI() {
        super.setupUI()
        // 插入视图
        contentView.insertSubview(backBtn, belowSubview: pictureView)
        contentView.insertSubview(retweetText, aboveSubview: backBtn)
        // 布局按钮
        backBtn.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: labText, size: nil, offset: CGPoint(x: -DHStatusCellMargin, y: DHStatusCellMargin))
        backBtn.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        retweetText.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backBtn, size: nil, offset: CGPoint(x: DHStatusCellMargin, y: DHStatusCellMargin))
        // 图片约束
        let con = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: retweetText, size: CGSize(width: DHPictuerMaxWH, height: DHPictuerMaxWH), offset: CGPoint(x: 0, y: DHStatusCellMargin))
        
        // 记录约束
        pictureViewWidthCons = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCons = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Height)
        pictureViewTopCons = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Top) // 顶部约束
        
        
    }
    
    // 背景设置为一个按钮
    private lazy var backBtn: UIButton = {
       let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.85, alpha: 1)
        return btn
    }()
    
    private lazy var retweetText: UILabel = UILabel(title: "!!@!@!@!@!", color: UIColor.darkGrayColor(), fontSize: 15, layoutWidth: UIScreen.mainScreen().bounds.width - 2*DHStatusCellMargin)
}
